/*
 * @Author: xushuhao
 * @Email: xshmouse@163.com
 * @Date: 2020-05-06 14:17:39
 * @Last Modified by: xushuhao
 * @Last Modified time: 2020-05-06 16:08:22
 * @Description: 独立提示页：可做信息提示或咨询选择使用
 */

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_sfsymbols/flutter_sfsymbols.dart';

class XDialogPage extends StatefulWidget {
  String title;
  String message;
  String buttonName;
  Function callBack;
  XDialogPage(this.message,
      {Key key, this.title = '信息提示', this.buttonName = '确定', this.callBack})
      : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return XDialogPageState();
  }
}

class XDialogPageState extends State<XDialogPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Theme.of(context).backgroundColor,
      body: SafeArea(child:
          ListView.builder(
            itemCount: 1,
            itemBuilder: (BuildContext context, int index) {
        return Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Container(
              height: 62,
              child: Text(''), //占位
            ),
            Container(
              height: 56,
              alignment: AlignmentDirectional.centerStart,
              padding: EdgeInsets.fromLTRB(26, 0, 24, 0), //补2个视觉误差
              child: Icon(SFSymbols.bubble_left_bubble_right,
                  size: 58, color: Theme.of(context).primaryColor),
            ),
            Container(
              height: 88,
              alignment: AlignmentDirectional.centerStart,
              padding: EdgeInsets.fromLTRB(24, 0, 24, 0),
              child: Text(widget.title,
                  style: TextStyle(
                      fontSize: 28,
                      color:
                          Theme.of(context).primaryTextTheme.display4.color)),
            ),
            Container(
              alignment: AlignmentDirectional.centerStart,
              padding: EdgeInsets.fromLTRB(24, 0, 24, 50),
              child: Text(widget.message,
                  style: TextStyle(
                      fontSize: 18,
                      color: Theme.of(context).primaryTextTheme.title.color)),
            ),
            Container(
              padding: EdgeInsets.fromLTRB(24, 0, 24, 0),
              width: 136,
              child: GestureDetector(
                child: Container(
                  height: 50,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                    color: Theme.of(context).primaryColor,
                    border: Border.all(color: Theme.of(context).primaryColor),
                    borderRadius: BorderRadius.all(Radius.circular(5)),
                  ),
                  child: Text(
                    widget.buttonName,
                    style: TextStyle(
                        fontSize: 16, color: Theme.of(context).backgroundColor),
                  ),
                ),
                onTap: widget.callBack,
              ),
            ),
            Container(
              height: 16,
              child: Text(''), //占位
            ),
            Container(
              width: 136,
              padding: EdgeInsets.fromLTRB(26, 0, 26, 0),
              child: GestureDetector(
                  child: Container(
                    alignment: Alignment.center,
                    height: 50,
                    decoration: BoxDecoration(
                      color: Theme.of(context).backgroundColor,
                      border: Border.all(color: Theme.of(context).primaryColor),
                      borderRadius: BorderRadius.all(Radius.circular(5)),
                    ),
                    child: Text(
                      '取消',
                      style: TextStyle(
                          fontSize: 16, color: Theme.of(context).primaryColor),
                    ),
                  ),
                  onTap: () {
                    Navigator.of(context).pop();
                  }),
            ),
            Container(
              height: 40,
              child: Text(''), //占位
            ),
          ],
        );
      })),
    );
  }
}
